home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 27 / 027.d81 / all base calc (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  4KB  |  128 lines

  1. 5 h1$="[145]"+chr$(13)+""
  2. 6 h2$="[145]"+chr$(13)+""
  3. 7 vt$=""
  4. 10 rem base do-it-all
  5. 15 :
  6. 20 rem by tom phelps
  7. 23 :
  8. 24 rem university of illinois
  9. 25 rem finite math camp
  10. 27 :
  11. 40 rem 
  12. 50 print"[147]";:poke53280,6:poke53281,6
  13. 80 :
  14. 95 gosub 60000
  15. 100 ans$ = "0":b3 = 0
  16. 110 for i = 1 to 4: read opr$(i): next i: data +,-,*,/
  17. 1000 rem
  18. 1010 print"[147]                                        ";
  19. 1020 printchr$(18)"           [193]ll [194]ase [195]alculator          ";
  20. 1030 print"                                        [146]"
  21. 1050 pv$ = ans$:pv = c3 + 2 *abs((c3 = 0))
  22. 1060 print "[208]revious answer :":print pv$:print"[194]ase "pv
  23. 1070 rem
  24. 1075 b1$="":a$="":opr$="":b2$="":b3$=""
  25. 1076 printvt$;:forcl=1to2
  26. 1077 print"                                       ":next
  27. 1079 print""tab(20)"[215]hole numbers only!":printtab(26)"'exit' to quit"
  28. 1080 print "[198]irst number"chr$(13)"[183][183][183][183][183][183][183][183][183][183][183][183]"
  29. 1090 input "[206]umber ";b1$:iflen(b1$)>8then1000
  30. 1095 ifb1$=""goto1080
  31. 1100 ifb1$="exit"thenprintchr$(147):goto63000
  32. 1110 if b1$ <>"pv"then1200
  33. 1120 b1$ = pv$:b1% = pv
  34. 1130 print "[206]umber ? "b1$"  "
  35. 1140 print"[194]ase ?"b1%
  36. 1190 goto 1230
  37. 1200 print ""
  38. 1210 input"[194]ase ";a$:ifa$="restart"then1075
  39. 1212 iflen(a$)>2then52000
  40. 1215 a$=left$(a$,2)
  41. 1220 b1%=val(a$):ifb1%<2orb1%>62goto1200
  42. 1230 c1=b1%
  43. 1232 x=b1%+48:ifx>57thenx=x+8
  44. 1233 forj=1tolen(b1$):bb$=mid$(b1$,j,1)
  45. 1235 ifasc(bb$)>=xthenprintvt$"[206]o way, [202]ose'! [212]here is no such number!"
  46. 1237 ifasc(bb$)>=xthenprint"[208]ress a key.";:poke198,0:wait198,1:geta$:goto1075
  47. 1238 next
  48. 1240 rem
  49. 1400 print""h1$"[157][157](+, -, *, /, =)"
  50. 1405 printh1$;
  51. 1410 print"[207]perator ";
  52. 1412 getopr$:ifopr$=""then1412
  53. 1415 if opr$ = "r" then 1075
  54. 1420 ifopr$="="thenopr=0:goto1700
  55. 1430 fori=1to4:ifopr$=opr$(i)thenopr=i: goto1470
  56. 1440 nexti
  57. 1450 goto 1400
  58. 1460 :
  59. 1470 printvt$;:forcl=1to2
  60. 1480 print"                                       ":next
  61. 1500 print""h2$"[211]econd number"chr$(13)h2$"[183][183][183][183][183][183][183][183][183][183][183][183][183]"
  62. 1505 printh2$;
  63. 1510 input "[206]umber ";b2$:iflen(b2$)>8then52000
  64. 1515 if b2$ = "" then  print:goto 1500
  65. 1520 if b2$ = "restart" then 1075
  66. 1600 print""h2$;
  67. 1605 a$=""
  68. 1610 input"[194]ase ";a$:ifa$="restart"then1075
  69. 1614 iflen(a$)>2then 52000
  70. 1620 b2%=val(a$):if b2%<2orb2%>62thenprintchr$(7):goto1600
  71. 1630 c2=b2%
  72. 1632 x=b2%+48:ifx>57thenx=x+8
  73. 1633 forj=1tolen(b2$):bb$=mid$(b2$,j,1)
  74. 1640 ifasc(bb$)>=xthenprintvt$"[206]o way, [202]ose'! [212]here is no such number!"
  75. 1650 ifasc(bb$)>=xthenprint"[208]ress a key.";:poke198,0:wait198,1:geta$:goto1460
  76. 1655 next
  77. 1700 print"[206]ow enter what base the answer should"
  78. 1705 print "be in.": print 
  79. 1710 input "-> ";b3$:b3$=left$(b3$,2):ifb3$="re"then1075
  80. 1720 b3%=val(b3$):ifb3%<2orb3%>62goto1700
  81. 1730 c3=b3%
  82. 1800 gosub 5500
  83. 1805 forcl=19to4step-1:print"":forc2=1tocl:print:next
  84. 1806 print"                                       ":next
  85. 1810 print"[193]nswer:  "
  86. 1811 printspc(27-len(b1$))b1$" (base "b1%"[157])"
  87. 1812 printspc(27-len(b2$)-2)op$" "b2$" (base "b2%"[157])"
  88. 1813 forqd=1to38:print"-";:next:print
  89. 1814 iflen(an$)>26thenan$="0":52000
  90. 1815 printspc(27-len(an$))an$" (base "b3%"[157])"
  91. 1820 print"[193]ny key ";:poke198,0:wait198,1:get a$
  92. 1821 b2$="":b2% = 0
  93. 1830 goto1000
  94. 5500 bin$ = b1$:b = c1: gosub 6010:b1 = dec
  95. 5520 if opr=0then ans = b1: goto 5700
  96. 5530 bin$ = b2$:b = c2: gosub 6010:b2 = dec
  97. 5540 if opr = 1 then ans = b1 + b2
  98. 5550 if opr = 2 then ans = b1 - b2
  99. 5560 if opr = 3 then ans = b1 * b2
  100. 5570 if opr = 4 then ifb2<>0thenans = b1 / b2:goto5700
  101. 5580 if opr=4thenprint" [196]on't divide by zero...":fordl=1to1000:next:goto1000
  102. 5700 dec = ans:b = c3: gosub 6000
  103. 5710 ans$ = bin$: return 
  104. 6000 bin$="":fori=0to1step0:r=int(((dec/b-int(dec/b))*b)+.0001)
  105. 6003 bin$=chr$(r+abs((r<10))*48+abs((r>9))*55)+bin$
  106. 6004 dec=int(dec/b):i=abs((dec<1)):next
  107. 6005 return 
  108. 6010 dec=0:fori=len(bin$)to1step-1:r=asc(mid$(bin$,i,1))-48:r=r-abs((r>9))*7
  109. 6015 dec=dec+r*b^(len(bin$)-i):next
  110. 6020 return 
  111. 10000 x=x+48:ifx>57thenx=x+8
  112. 52000 print"[147][201]llegal [214]alue!":fort=1to1000:next:goto1000
  113. 60000 printchr$(18)"                                        ";
  114. 60005 printchr$(18)"            [204]oadstar [208]resents           ";
  115. 60010 printchr$(18)"           [193]ll [194]ase [195]alculator          ";
  116. 60015 printchr$(18)"                                        "
  117. 60020 print  tab( 19)"by"
  118. 60060 print : print  tab( 15)"[212]om [208]helps"
  119. 60070 print : print  tab( 13)"[195]opyright 1986"
  120. 60090 print "     [204]oadstar is not public domain."
  121. 60100 print : print "   [208]lease respect the author's rights."
  122. 60200 print : print  tab( 15)"[208]ress a key";:poke198,0:wait198,1:get k$
  123. 60300 return 
  124. 63000 rem  re-connect
  125. 63010 open15,8,15,"r0:hello connect=hello connect":input#15,er:close15
  126. 63020 ifer<>63thenend
  127. 63030 load"hello connect",8
  128.